package com.example.smartcity.ui.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.smartcity.R;
import com.example.smartcity.ui.Bean.CommunityBannerBean;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;
import java.util.zip.Inflater;

public class CommunityBannerTitleAdapter extends BannerAdapter<CommunityBannerBean.RowsBean,CommunityBannerTitleAdapter.MyViewHolder>{
    int resource;

    public CommunityBannerTitleAdapter(List<CommunityBannerBean.RowsBean> datas,int resource) {
        super(datas);
        this.resource = resource;
    }

    @Override
    public MyViewHolder onCreateHolder(ViewGroup viewGroup, int i) {
        return new MyViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(resource,viewGroup,false));
    }

    @Override
    public void onBindView(MyViewHolder myViewHolder, CommunityBannerBean.RowsBean rowsBean, int i, int i1) {
        myViewHolder.TV_AdTitle.setText(rowsBean.getTitle());
        myViewHolder.TVAdName.setText(rowsBean.getContent());
        myViewHolder.TVPosition.setText(rowsBean.getPosition());
        myViewHolder.TVTime.setText(rowsBean.getCreateTime());
    }


    static class MyViewHolder extends RecyclerView.ViewHolder{
        private TextView TVAdName;
        private TextView TVPosition;
        private TextView TVTime;
        private TextView TV_AdTitle;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            TVAdName = itemView.findViewById(R.id.TV_adName);
            TVPosition = itemView.findViewById(R.id.TV_position);
            TVTime = itemView.findViewById(R.id.TV_time);
            TV_AdTitle = itemView.findViewById(R.id.TV_AdTitle);
        }
    }
}
